using System;
using UnityEngine;
using UnityEngine.Playables;

public class IntroController : MonoBehaviour
{
   public PlayableDirector director;
   
   public ObjectEventSO loadMainMenuEvent;

   private void Awake()
   {
      director = GetComponent<PlayableDirector>();
      director.stopped += OnPlayableDirectorStopped;
   }

   private void Update()
   {
      if (Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown(KeyCode.Mouse0)
          && director.state == PlayState.Playing)
      {
         director.Stop();
      }
   }

   private void OnPlayableDirectorStopped(PlayableDirector obj)
   {
      loadMainMenuEvent.RaisEvent(null,this);
   }
}
